local reward_table = {
	[1] = 2188, [2] = 2181, [3] = 2455, [4] = 0
}
if reward_table[5] == nil then
	reward_table[5] = reward_table[1]
	reward_table[6] = reward_table[2]
	reward_table[7] = reward_table[3]
	reward_table[8] = reward_table[4]
end

local knight_table_reward = {
	[LEVEL_SKILL_CLUB] = 2423, [LEVEL_SKILL_AXE] = 2429,[LEVEL_SKILL_SWORD] = 2383
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local reward, storage = reward_table[getPlayerVocation(cid)], item.uid
	local descr, ret = nil, false
	
	if(getPlayerStorageValue(cid, storage) > 0) then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
		return true
	end
	
	local skill_club, skill_axe, skill_sword = getPlayerSkill(cid, LEVEL_SKILL_CLUB), getPlayerSkill(cid, LEVEL_SKILL_AXE), getPlayerSkill(cid, LEVEL_SKILL_SWORD)
	--- 	//doPlayerAddItem(cid, itemid, <optional: default: 1> count, <optional: default: 1> canDropOnMap, <optional: default: 1>subtype)
	if reward == 0 then
		if skill_sword >= skill_axe and skill_sword >= skill_club then
			-- spike sword
			reward = knight_table_reward[LEVEL_SKILL_SWORD]
		elseif skill_axe >= skill_club then
			-- barbarian axe
			reward = knight_table_reward[LEVEL_SKILL_AXE]
		else
			-- clerical mace
			reward = knight_table_reward[LEVEL_SKILL_CLUB]
		end
		--- knight
	end
	ret = doPlayerAddItem(cid, reward, 1, 0, 1) ~= 0 and true or false
	descr = getItemDescriptions(reward)
	
	if not ret then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is too heavy or you have not enough space.')
		return true
	end
	setPlayerStorageValue(cid, storage, 1)
	doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found '..descr.article..' '..descr.name..'.')
	return true
end